New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stacks/common

Package Overview
Dependencies
Maintainers
0
Versions
619
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/common

Common Stacks utilities

  • 6.16.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is @stacks/common?

@stacks/common is a utility library that provides a set of common functions and utilities used across the Stacks ecosystem. It includes functions for data manipulation, encoding/decoding, and other helper utilities that facilitate development within the Stacks blockchain environment.

What are @stacks/common's main functionalities?

Data Encoding/Decoding

This feature provides utilities for encoding and decoding data, such as converting strings to byte arrays and vice versa. This is useful for handling data in a format suitable for blockchain transactions.

const { utf8ToBytes, bytesToUtf8 } = require('@stacks/common');

const text = 'Hello, Stacks!';
const bytes = utf8ToBytes(text);
console.log(bytes); // Uint8Array of byte values

const decodedText = bytesToUtf8(bytes);
console.log(decodedText); // 'Hello, Stacks!'

Hex Encoding/Decoding

This feature allows for conversion between hexadecimal strings and byte arrays, which is essential for handling cryptographic data and transaction payloads in blockchain applications.

const { hexToBytes, bytesToHex } = require('@stacks/common');

const hexString = '48656c6c6f';
const bytes = hexToBytes(hexString);
console.log(bytes); // Uint8Array of byte values

const hex = bytesToHex(bytes);
console.log(hex); // '48656c6c6f'

Buffer Utilities

This feature provides utilities for working with buffers, such as concatenating multiple byte arrays. This is useful for constructing data payloads that need to be sent over the network or stored on the blockchain.

const { concatBytes } = require('@stacks/common');

const buffer1 = new Uint8Array([1, 2, 3]);
const buffer2 = new Uint8Array([4, 5, 6]);
const combined = concatBytes(buffer1, buffer2);
console.log(combined); // Uint8Array [1, 2, 3, 4, 5, 6]

Other packages similar to @stacks/common

FAQs

Package last updated on 01 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc